#include "game.h"

void game::click(int id, int row, int col){
    //若不是红方突出
    if(!(this->_bRedTurn)){
        return;
    }
    //是红方执行
    Board::click(id,row,col);
    //是黑方电脑操作
    if(!(this->_bRedTurn)){
        Step* step=computermove();
        moveqizi(step->_moveid,step->_killid,step->_rowTo,step->_colTo);
    }
}

void game::getallposmove(QVector<Step *> &steps){
    for(int i=16;i<31;i++){
        for(int row=0;row<9;row++){
            for(int col=0;col<=8;col++){
                int killid=this->getqiziId(row,col);
                if(samecolor(killid,i)){
                    continue;
                }
                if(canMove(i,row,col,killid)){
                    saveStep(i,killid,row,col,steps);
                }
            }
        }
    }
}

void fakemove(Step* step){
  // killqizi(step->_killid);
   //moveqizi(step->_moveid,step->_rowTo,step->_colTo);
}

void unfakemove(Step* step){
   // reliveqizi(step->_killid);
    //moveqizi(step->_moveid,step->_rowFrom,step->_colFrom);
}

int calscore(){

}

Step* game::computermove(){
     QVector<Step*> steps;
     getallposmove(steps);
     int maxscore=-100000000;
     Step* ret;
     for(QVector<Step*>::iterator it=steps.begin();it!=steps.end();it++){
         Step* step=*it;
        /*fakemove(step);
         int score=calScore();
         unfakemove(step);
       if(score>maxscore){
             maxscore=score;
             ret=step;
         }*/
     }
     return ret;

 }
